import { _decorator, Component, Node } from 'cc';
import { yy } from 'yycore';

import { YYLangEn } from '../../yycoreLang/YYCoreLangEn';

const { ccclass, property } = _decorator;


/**
 * yycore多语言插件
 */
@ccclass('YYCoreLang')
export class YYCoreLang extends Component {


    protected onLoad(): void {
        this.senlang("en", YYLangEn);

        // 初始化框架多语言
        yy.sys.setCurrentLanguage('en');
    }

    // 设置框架多语言数据
    private senlang(lan: string, jsobj: any) {
        const lanText = yy.sys.languageCenter.getTextCenter(lan)
        for (let i = 1; i <= 16; i++) {
            const obj = jsobj["module" + i];
            for (const key in obj) {
                lanText.setText(i, parseInt(key), obj[key]);
            }
        }
    }
}

